package com.jiangyg.mall.coupon.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.coupon.dao.SeckillSkuNoticeDao;
import com.jiangyg.mall.coupon.dto.SeckillSkuNoticeDTO;
import com.jiangyg.mall.coupon.entity.SeckillSkuNotice;
import com.jiangyg.mall.coupon.vo.SeckillSkuNoticeVO;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SeckillSkuNoticeServiceImpl extends BaseServiceImpl<SeckillSkuNoticeDao, SeckillSkuNotice> implements SeckillSkuNoticeService {

    @Autowired
    public SeckillSkuNoticeServiceImpl(SeckillSkuNoticeDao seckillSkuNoticeDao) {
        super(seckillSkuNoticeDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<SeckillSkuNoticeVO> selectPagination(Pagination<SeckillSkuNoticeVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, SeckillSkuNoticeVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(SeckillSkuNoticeDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public SeckillSkuNoticeVO selectById(Long seckillSkuNoticeId) throws Exception {
        return this.executeSelectById(seckillSkuNoticeId, SeckillSkuNoticeVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> seckillSkuNoticeIds) {
        return this.baseMapper.deleteBatchIds(seckillSkuNoticeIds) > 0;
    }

}
